package com.study.zzedu.adapter;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.v7.widget.RecyclerView;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.study.zzedu.R;
import com.study.zzedu.entity.DiscussDetailItem;
import com.study.zzedu.entity.TuitionModel;

import java.util.List;

public class DiscussDetailAdapter extends RecyclerView.Adapter<DiscussDetailAdapter.ViewHolder> {
    private List<DiscussDetailItem> m;

    public class ViewHolder extends RecyclerView.ViewHolder
    {
        private TextView tv_author,tv_time,tv_identify,tv_detail;
        private Button btn_tuition_go;
        public ViewHolder(View view){
            super(view);
            tv_author = (TextView) view.findViewById(R.id.tv_author);
            tv_time = (TextView)  view.findViewById(R.id.tv_time);
            tv_identify = (TextView)  view.findViewById(R.id.tv_identify);
            tv_detail = (TextView)  view.findViewById(R.id.tv_detail);
        }
    }

    public DiscussDetailAdapter(List<DiscussDetailItem> tModel) {
        m = tModel;
    }

    public ViewHolder onCreateViewHolder(ViewGroup parent, int Viewtype) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.discuss_detail_item, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @SuppressLint("ResourceAsColor")
    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        DiscussDetailItem tModel = m.get(position);
        holder.tv_detail. setText(tModel.getContent());
        holder.tv_time.setText("发布于 " + tModel.getPubdate());
        holder.tv_author.setText(tModel.getReplierName());
    }

    public int getItemCount() {
        return m.size();
    }
}